use axum::{
    routing::{post, get, delete},
    Router,
    middleware,
};
use crate::{
    handlers::ai::{
        chat, 
        get_chat_history, 
        get_message_history,
        create_conversation,
        delete_conversations,
        create_message
    },
    services::{AiService, UserService},
    middleware::auth::auth_middleware,
};

/// AI相关路由
pub fn ai_routes(ai_service: AiService, user_service: UserService) -> Router {
    Router::new()
        .route("/chat", post(chat).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .route("/history", get(get_chat_history).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .route("/message_history", get(get_message_history).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .route("/create_conversation", get(create_conversation).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .route("/delete_conversations", delete(delete_conversations).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .route("/create_message", post(create_message).layer(middleware::from_fn_with_state(
            user_service.clone(),
            auth_middleware,
        )))
        .with_state(ai_service)
        .with_state(user_service)
} 